#ifndef __ARTIST_PROCESS_H__
#define __ARTIST_PROCESS_H__

#define  STATE_BORN            (0)
#define  STATE_READY           (1)
#define  STATE_RUNNING         (2)
#define  STATE_NOSTOP          (3)
#define  STATE_WAIT            (4)
#define  STATE_STOPPED         (5)
#define  STATE_ZOMBIE          (6)
/*When the state is STATE_CAPTURED ,it means the process is arrested by the os,when the os finish 
   its work,the os will release it.*/
#define  STATE_CAPTURED        (7)

struct struct_process;
typedef struct struct_process* PPROCESS;

typedef  struct struct_idgroup
         {
             U4B  uid;
             U4B  gid;
             U4B  euid;
             U4B  egid;
             U4B  suid;
             U4B  sgid;
         }IDGROUP;


typedef  struct struct_familytree
         {
             PPROCESS   pparent;
             PPROCESS   pfirstson;
             PPROCESS   plastson;
             PPROCESS   pprev;
             PPROCESS   pnext;
         }FAMILYTREE;

typedef  struct struct_sectiongroup
         {
            U4B  codestart;
            U4B  codeend;
            U4B  datastart;
            U4B  dataend;
            U4B  stackstart;
            U4B  stackend;
         }SECTIONGROUP;
typedef  struct struct_pde
         {
           U4B  pde[1024];
         }PDE;
typedef  struct struct_pte
         {
           U4B  pte[1024];
         }PTE;
typedef  struct struct_pde*  PPDE;
typedef  struct struct_pte*  PPTE;
typedef  struct struct_process
         {
            ARCREGISTER  p_arcregister;
            CHAR         p_name[PROCESS_MAXNAME];
			
			U4B          p_pid;
            U4B          p_priority;
			
            U4B          p_remain;
            U4B          p_state;
			
            U4B          p_waitsource;
            U4B          p_waitsignal;
            U4B          p_waittick;/*when the state:wait,0 present forever  */
            U4B          p_signalreturn;

            U4B          p_exit;
			
            U4B          p_tty;
            U4B          p_session;
			
            U4B          p_leader;
            U4B          p_starttime;
			
            U4B          p_endtime;
            U4B          p_group[128];
            U4B          p_alarmtime;
			
            U4B          p_pgrp;
            U4B          p_processsize;
			
            U4B          p_blocknumber;
            U4B          p_idcard;         /*0:kernel,over 100:usr  .It's used to distinguish the user process from the kernel...*/

            MESSAGE      p_messageshack;
            PPROCESS     p_messagequeue;
            PPROCESS     p_messageheader;

            U4B          p_filenumber;
            #define PFILE  PU4B
            PFILE         p_pfile;
            #undef  PFILE


            U4B          p_messageplace;
            PMESSAGE     p_pmessage;
            U4B          p_messagelimit;
            U4B          p_messageget;

            U4B          p_signalplace;
            PSIGNAL      p_psignal;
            U4B          p_signallimit;
            U4B          p_signalget;

            IDGROUP      p_idgroup;
            FAMILYTREE   p_familytree;
            SECTIONGROUP p_sectiongroup;
			
            #define  PPAGEBLOCK  struct struct_pageblock*
            PPAGEBLOCK   p_pstartpageblock;
            PPAGEBLOCK   p_pendpageblock;
            #undef   PPAGEBLOCK
			
            PPDE         p_ppde;
			
            PPROCESS     p_sharecodeprev;
			PPROCESS     p_sharecodenext;
            PPROCESS     p_pscheduleprev;
            PPROCESS     p_pschedulenext;
            PPROCESS     p_pprocessprev;
            PPROCESS     p_pprocessnext;
         }PROCESS;
S4B Activate(PPROCESS pprocess);
S4B ActivateProcess(PPROCESS pprocess);
PUBLIC S4B InitUserPCB
	(PPROCESS p, U4B pid,   PVOID entry,U4B stack, PVOID messagestack,
	 PVOID signalstack,   U4B priority,
	 PCHAR name, PPDE ppde,  PPROCESS prev,PPROCESS next);

#endif
